# 字典练习题
# 输出股票信息
# header = ['股票名称', '当前价', '涨跌额']
# stock_dict = {
#     'SZ000001': ['平安银行', '6.29', '+1.92'],
#     'SZ000002': ['万科A', '23.29', '+6.92'],
#     'SZ000004': ['国华网安', '56.29', '+12.92'],
#     'SZ000005': ['世纪星源', '6.00', '+0.92'],
# }
# for keys , values in stock_dict.items():
#     text_list = []
#     for index in range(len(values)):
#         text = "{}:{}".format(header[index],values[index])
#         text_list.append(text)
#     data = "、".join(text_list)
#     reslut = "{},{}。".format(keys,data)
#     print(reslut)

# dic = {'k1': "v1", "k2": "v2", "k3": [11, 22, 33]}
# # 请在字典中添加一个键值对，"k4": "v4"，输出添加后的字典
# dic.setdefault("k4", "v4")
# dic['k4'] = "v4
# print(dic)
# # 请在修改字典中 "k1" 对应的值为 "alex"，输出修改后的字典
# dic.update({"k1": "alex"})
# dic['k1'] = "alex"
# print(dic)
# # 请在k3对应的值中追加一个元素 44，输出修改后的字典
# dic.get("k3").append(44)
# print(dic)
# # 请在k3对应的值的第 1 个位置插入个元素 18，输出修改后的字典
# dic.get("k3").insert(0, 18)
# print(dic)

dic1 = {
 'name':['alex',2,3,5],
 'job':'teacher',
 'oldboy':{'alex':['python1','python2',100]}
}
#
# # 1，将name对应的列表追加⼀个元素’wusir’。
# dic1.get("name").append("wusir")
# print(dic1)
# # 2，将name对应的列表中的alex全变成大写。
# name = dic1.get("name")[0].upper()
# dic1.get("name")[0] = name
# print(dic1)
# # 3，oldboy对应的字典加⼀个键值对’⽼男孩’:’linux’。
# dic1.get("oldboy").update({"⽼男孩":"linux"})
# dic1['oldboy']['老男孩'] = "linux"
# print(dic1)
# # 4，将oldboy对应的字典中的alex对应的列表中的python2删除
# dic1.get("oldboy").get("alex").pop(1)
# dic1.get("oldboy").get("alex").remove("python2")
# print(dic1)

# data = {}
# while True:
# 	name = input("输入姓名:")
# 	if name.upper() == "Q":
# 		break
# 	lis = name.split("|")
# 	print(lis)
# 	data.setdefault(lis[0], lis[1])
# print(data)

# key_list = []
# value_list = []
# info = {'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}
# for key, value in info.items():
# 	key_list.append(key)
# 	value_list.append(value)
# key_list = list(info.keys())
# value_list = list(info.values())
# print(key_list)
# print(value_list)

# dic = {'k1': "v1", "k2": "v2", "k3": [11,22,33]}
# print(dic.keys())
# print(dic.values())
# print(dic.items())

# info = {
#     'k1':'v1',
#     'k2':[('alex'),('wupeiqi'),('oldboy')],
# }
# for item in range(len(info.get("k2"))):
# 	print(info.get("k2")[item])

# message = "k: 1|k1:2|k2:3  |k3 :4".split("|")
# print(message)
# dic = {}
# for item in message:
# 	lis = item.strip().split(":")
	# print(lis)
	# dic.setdefault(lis[0], lis[1])
# 	v1,v2 = item.strip().split(":")
# 	dic.setdefault(v1, v2)
# print(dic)
li = [11, 22, 33, 44, 55, 66, 77, 88, 99, 90]
# lis1 = []
# lis2 = []
# for item in li:
# 	if item > 66:
# 		lis1.append(item)
# 	elif item<66:
# 		lis2.append(item)
# 	else:
# 		pass
dic = {}
# dic.setdefault("k1",lis1)
# dic.setdefault("k2",lis2)
# for item in li:
# 	if item>66:
# 		if "k1" in dic:
# 			dic["k1"].append(item)
# 		else:
# 			dic["k1"] = [item]
# 	elif item ==66:
# 		pass
# 	else:
# 		if "k2" in dic:
# 			dic["k2"].append(item)
# 		else:
# 			dic["k2"] = [item]
# print(dic)

"""
商品列表：
  goods = [
		{"name": "电脑", "price": 1999},
		{"name": "鼠标", "price": 10},
		{"name": "游艇", "price": 20},
		{"name": "美女", "price": 998}
	]
要求:
1：页面显示 序号 + 商品名称 + 商品价格，如：
      1 电脑 1999
      2 鼠标 10
	  ...
2：用户输入选择的商品序号，然后打印商品名称及商品价格
3：如果用户输入的商品序号有误，则提示输入有误，并重新输入。
4：用户输入Q或者q，退出程序。
"""
# goods = [
# 	{"name": "电脑", "price": 1999},
# 	{"name": "鼠标", "price": 10},
# 	{"name": "游艇", "price": 20},
# 	{"name": "美女", "price": 998}
# ]
# lis = []
# for good in range(len(goods)):
# 	# print(goods[good].get("price"))
# 	lis.append("{} {} {}".format(good + 1, goods[good].get("name"), goods[good].get("price")))
# 	print(lis[good])
# while True:
# 	select = input("输入选择的数字:")
# 	if select.upper() == "Q":
# 		print("退出成功")
# 		break
# 	if not select.isdecimal():
# 		print("输入有误")
# 		break
# 	num = int(select)
# 	if num > 4 or num < 0:
# 		print("超出范围")
# 		break
# 	print(lis[int(int(select) - 1)])

